<?php get_header() ?>
<div id="content">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post() ?>
<!-- google_ad_section_start -->
<div class="post">
<?php edit_post_link('Edit','<p class="edit">','</p>') ?>
<h1 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark"><?php if ( get_the_title() ){ the_title(); }else{ echo "Untitled"; } ?></a></h1>
<?php if ( post_excerpt() & ( get_the_content() || !get_the_guid() ) ) : ?>
<?php if ( trim(get_the_excerpt()) != "" ){ the_excerpt(); }else{ echo '<p>...</p>'; } ?>
<p><a href="#article">The article starts below...</a></p>
<p><cite>
Written by <?php the_author() ?> on <a href="<?php echo get_day_link(get_the_time('Y'),get_the_time('m'),get_the_time('d')) ?>" title="View all posts written on <?php the_time('F jS, Y') ?>"><?php the_time('F jS, Y') ?></a> with
<?php if ( 'open' == $post->comment_status ) : ?>
<a href="#comments" title="Comment on <?php if ( get_the_title() ){ the_title(); }else{ echo "Untitled"; } ?>"><?php comments_number('no comments','1 comment','% comments') ?></a>.<br />
<?php else : // 'open' == $post->comment_status ?>
comments disabled.<br />
<?php endif // 'open' == $post->comment_status ?>
Read more articles on <?php the_category(' and ') ?>.
</cite></p>
</div>
<!-- google_ad_section_end -->
<?php include (TEMPLATEPATH.'/ad2.php') ?>
<!-- google_ad_section_start -->
<a name="article"></a>
<div class="post">
<?php edit_post_link('Edit','<p class="edit">','</p>') ?>
<?php endif // post_excerpt() & ( get_the_content() || !get_the_guid() ) ?>
<?php if ( get_the_content("", false, "") ){ the_content(); }elseif ( get_the_guid() ){ echo "<p><a href=\"".get_the_guid()."\"><img src=\"".get_the_guid()."\" alt=\"Click to enlarge\" class=\"thumbnail\" /></a></p>"; }else{ echo "<p>...</p>"; } ?>
<?php link_pages('<p>More pages: ', '</p>', 'number'); ?>
<p><cite>
Written by <?php the_author() ?> on <a href="<?php echo get_day_link(get_the_time('Y'),get_the_time('m'),get_the_time('d')) ?>" title="View all posts written on <?php the_time('F jS, Y') ?>"><?php the_time('F jS, Y') ?></a> with
<?php if ( 'open' == $post->comment_status ) : ?>
<a href="#comments" title="Comment on <?php if ( get_the_title() ){ the_title(); }else{ echo "Untitled"; } ?>"><?php comments_number('no comments','1 comment','% comments') ?></a>.<br />
<?php else : // 'open' == $post->comment_status ?>
comments disabled.<br />
<?php endif // 'open' == $post->comment_status ?>
Read more articles on <?php the_category(' and ') ?>.
</cite></p>
<ul>
<li><a href="http://digg.com/submit?phase=2&amp;url=<?php echo urlencode(get_permalink()) ?>">[+] Digg</a>: Feature this article</li>
<li><a href="http://del.icio.us/post?url=<?php echo urlencode(get_permalink()) ?>&amp;title=<?php echo urlencode( get_the_title() ) ?>">[+] Del.icio.us</a>: Bookmark this article</li>
<li><a href="http://www.furl.net/store?s=f&amp;to=0&amp;ti=<?php echo urlencode(get_permalink()) ?>&amp;t=<?php echo urlencode( get_the_title() ) ?>">[+] Furl</a>: Bookmark this article</li>
</ul>
</div>
<!-- google_ad_section_end -->
<?php if ( post_excerpt() & ( get_the_content() || !get_the_guid() ) ) : ?>
<?php include (TEMPLATEPATH.'/ad3.php') ?>
<?php else : // post_excerpt() & ( get_the_content() || !get_the_guid() ) ?>
<?php include (TEMPLATEPATH.'/ad2.php') ?>
<?php endif // post_excerpt() & ( get_the_content() || !get_the_guid() ) ?>
<?php
$this_post = $post;
$category = get_the_category(); $category = $category[0]; $category = $category->cat_ID;
$posts = get_posts('numberposts=6&offset=0&orderby=post_date&order=DESC&category='.$category);
$count = 0;
foreach ( $posts as $post ) {
if ( $post->ID == $this_post->ID || $count == 5) {
unset($posts[$count]);
}else{
$count ++;
}
}
?>
<?php if ( $posts ) : ?>
<div class="post">
<h2>Related articles</h2>
<ul>
<?php foreach ( $posts as $post ) : ?>
<li><a href="<?php the_permalink() ?>" title="<?php echo trim(str_replace("\n"," ",preg_replace('#<[^>]*?>#si','',get_the_excerpt()))) ?>"><?php if ( get_the_title() ){ the_title(); }else{ echo "Untitled"; } ?></a> (<?php the_time('F jS, Y') ?>)</li>
<?php endforeach // $posts as $post ?>
</ul>
</div>
<?php endif // $posts ?>
<?php
$post = $this_post;
unset($this_post);
?>
<?php comments_template() ?>
<?php endwhile // have_posts()?>
<?php else : // have_posts()?>
<div class="block">
<h1>Not found</h1>
<p>Sorry, but we are unable to find any article matching your request.</p>
</div>
<?php include (TEMPLATEPATH.'/ad2.php') ?>
<?php endif // have_posts() ?>
<?php include (TEMPLATEPATH.'/ad4.php') ?>
</div>
<?php get_sidebar() ?>
<?php get_footer() ?>
